package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IAiImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * AI图片生成控制器
 */
@RestController
@RequestMapping("/ai")
public class AiImageController extends BaseController {
    
    @Autowired
    private IAiImageService aiImageService;

    /**
     * 生成图片
     */
    @PostMapping("/generate-image")
    @Log(title = "AI图片生成", businessType = BusinessType.INSERT)
    public AjaxResult generateImage(@RequestBody GenerateImageRequest request) {
        try {
            String imageUrl = aiImageService.generateImage(request.getPrompt());
            return AjaxResult.success("生成成功", imageUrl);
        } catch (Exception e) {
            return AjaxResult.error("生成失败：" + e.getMessage());
        }
    }
}

class GenerateImageRequest {
    private String prompt;

    public String getPrompt() {
        return prompt;
    }

    public void setPrompt(String prompt) {
        this.prompt = prompt;
    }
} 